
const { EventEmitter } = require('events');
const { setTimeout } = require('timers/promises');

const evt = new EventEmitter();

evt.on('hello',()=>console.log('hello event happen'));
evt.on('bye',()=>{
    console.log('good bye');
    process.exit();
});

setInterval(()=>{
    evt.emit('hello');
},1000);

setTimeout(()=>{
    evt.emit('bye');
},5000);